import Codes from '@/configs/Codes';
import AboutUs from '@/pages/about/AboutUs';
import ContactUs from '@/pages/about/ContactUs';
import Help from '@/pages/about/Help';
import Dashboard from '@/pages/dashboard';
import Analysis from '@/pages/dashboard/Analysis';
import Monitor from '@/pages/dashboard/Monitor';
import Workplace from '@/pages/dashboard/Workplace';
import Home from '@/pages/home/Home';
import Index from '@/pages/index/Index';
import Setting from '@/pages/setting';
import { AdvanceSetting } from '@/pages/setting/AdvanceSetting';
import { BasicSetting } from '@/pages/setting/BasicSetting';
import System from '@/pages/system';
import type { IRouteItem } from '@/routes/RouteType';
import { toBasePath } from '@/utils/PathUtil';
import { Navigate } from 'react-router-dom';

export const settingTabRoutes: IRouteItem[] = [
  {
    path: toBasePath(Codes.settingBasic),
    label: '基本设置',
    element: <BasicSetting />,
    hideInMenu: true,
  },
  {
    path: toBasePath(Codes.settingAdvance),
    label: '高级设置',
    element: <AdvanceSetting />,
    hideInMenu: true,
  },
];

export const homeRoutes: IRouteItem[] = [
  {
    path: toBasePath(Codes.home),
    label: '首页',
    element: <Home />,
  },
  {
    index: true,
    path: toBasePath(Codes.help),
    label: '帮助中心',
    element: <Help />,
  },
  {
    path: toBasePath(Codes.contactUs),
    label: '联系我们',
    element: <ContactUs />,
  },
  {
    path: 'http://www.baidu.com',
    label: '百度',
    redirect: 'http://www.baidu.com',
    target: '_blank',
  },
];

export const mainRoutes: IRouteItem[] = [
  {
    path: toBasePath(Codes.index),
    label: '首页',
    element: <Index />,
  },
  {
    path: toBasePath(Codes.system),
    label: '系统管理',
    element: <System />,
    showSider: true,
    children: [
      {
        path: toBasePath(Codes.system),
        label: '系统管理',
        element: <Navigate to={toBasePath(Codes.analysis)} />,
        hideInMenu: true,
      },
      {
        path: toBasePath(Codes.dashboard),
        label: '系统概览',
        element: <Dashboard />,
        hideInMenu: true,
        children: [
          {
            path: toBasePath(Codes.analysis),
            label: '分析页',
            element: <Analysis />,
          },
          {
            path: toBasePath(Codes.monitor),
            label: '监控页',
            element: <Monitor />,
          },
          {
            path: toBasePath(Codes.workplace),
            label: '工作台',
            element: <Workplace />,
          },
        ],
      },
      {
        path: toBasePath(Codes.setting),
        label: '系统设置',
        element: <Setting />,
        hideInMenu: true,
        children: [
          {
            path: toBasePath(Codes.setting),
            element: <Navigate to={toBasePath(Codes.settingBasic)} />,
            hideInMenu: true,
          },
          ...settingTabRoutes,
        ],
      },
    ],
  },
  {
    path: toBasePath(Codes.about),
    label: '关于',
    element: <AboutUs />,
  },
];
